import { FC, useRef } from 'react'
import { Input } from 'antd'

// 二次封装

interface SearchInputProps {
  getResultValue?: (val: string) => void
}

// 什么情况下获取input框中的内容，input失去焦点的时候

const SearchInput:FC<SearchInputProps> = (props) => {

  const { getResultValue } = props;

  const valDom:any = useRef()

  const hanleInputChangeValue = () => {
    console.log('valDom:', valDom.current.state.value)
    let currentValue = valDom.current.state.value;
    getResultValue && getResultValue(currentValue)
  }

  return <div>
    <Input ref={valDom} onBlur={hanleInputChangeValue}/>
  </div>
}

export default SearchInput;
